package com.tdtxdcxm.ruralcommunity.slice;

import com.tdtxdcxm.ruralcommunity.ResourceTable;
import com.tdtxdcxm.ruralcommunity.appruntime.DataCenterControl;
import com.tdtxdcxm.ruralcommunity.appruntime.UserConfigInfo;
import com.tdtxdcxm.ruralcommunity.httpmanagers.ThreadPoolUtil;
import com.tdtxdcxm.ruralcommunity.items.LCArryListContentItem;
import com.tdtxdcxm.ruralcommunity.items.LCArryListNormalItem;
import com.tdtxdcxm.ruralcommunity.myutils.MyTools;
import com.tdtxdcxm.ruralcommunity.providers.LCProviderForContent;
import com.tdtxdcxm.ruralcommunity.providers.LCProviderForNormal;
import com.tdtxdcxm.ruralcommunity.providers.PSProvider;
import ohos.aafwk.ability.AbilitySlice;
import ohos.aafwk.content.Intent;
import ohos.agp.colors.RgbColor;
import ohos.agp.components.*;
import ohos.agp.components.element.ShapeElement;
import ohos.net.NetHandle;
import ohos.net.NetManager;
import ohos.net.NetStatusCallback;
import ohos.utils.zson.ZSONObject;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLConnection;

public class MainAbilitySlice extends AbilitySlice {
    private Boolean toanotherslice = false;

    private Boolean[] worlddownonce = {false,false,false};
    private Boolean[] worldfieldonce = {false,false,false,false,false,false,false};
    private Boolean[] messageonce = {false,false,false};

    private final String[] bottomTabNames = {"首页","领域","➕","消息","我的"};
    private final String[] firstCenterTabNames = {"动态","项目","文章"};
    private final String[] secondCenterTabNames = {"艺","衣","食","住","行","学","文"};
    private final String[] fourthCenterTabNames = {"通知","点赞","评论","收藏"};

    private DirectionalLayout deepdl,deepdl_topdl,deepdl_centerdl,deepdl_bottomdl;
    private DirectionalLayout surfacedl;
    private DirectionalLayout surfacedl_writeselect;

    private TabList deepdl_bottomdl_tablist;

    private Button dt_but,xm_but,wz_but;


    /*<****************http构造表单上传销毁指令数据区域*****************/
    public void UpDataDestoryInfo(String username){
        NetManager main_toplistnetmanger = NetManager.getInstance(this.getContext());
        if (!main_toplistnetmanger.hasDefaultNet()) {
            return;
        }
        ThreadPoolUtil.submit(() -> {
            NetHandle thenetHandle = main_toplistnetmanger.getDefaultNet();
            NetStatusCallback netStatusCallback = new NetStatusCallback() {};
            HttpURLConnection httpURLConnection = null;

            String urlString = DataCenterControl.serverIpWithPort + "destory/?";
            try {
                URL url = new URL(urlString);

                ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
                URLConnection urlConnection = thenetHandle.openConnection(url, java.net.Proxy.NO_PROXY);
                if (urlConnection instanceof HttpURLConnection) {
                    httpURLConnection = (HttpURLConnection) urlConnection;

                    httpURLConnection.setRequestMethod("POST");
                    httpURLConnection.setDoOutput(true);

                    StringBuilder stringBuilder = new StringBuilder();

                    stringBuilder.append("username");
                    stringBuilder.append("=");
                    stringBuilder.append(username);


                    byte[] b = stringBuilder.toString().getBytes();
                    httpURLConnection.getOutputStream().write(b);

                    try {
                        httpURLConnection.connect();
                    } catch (IOException e) {}
                    outputStream.flush();


                    InputStream inputStream = null;
                    try {
                        inputStream = urlConnection.getInputStream();
                        byte[] cache = new byte[2 * 1024];
                        int len = inputStream.read(cache);
                        while (len != -1) {
                            outputStream.write(cache, 0, len);
                            len = inputStream.read(cache);
                        }
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                    String result = "";
                    result = outputStream.toString();
                    if(result.equals("OK")){
                        //销毁成功
                        UserConfigInfo.deleteUserInfo(MainAbilitySlice.this.getContext(),DataCenterControl.userName);
                        DataCenterControl.userName = "";
                        toanotherslice = true;
                        present(new StartPage(),new Intent());
                    }
                    else{
                        getUITaskDispatcher().asyncDispatch(new Runnable() {
                            @Override
                            public void run() {
                                MyTools.toastShow("销毁失败", MainAbilitySlice.this.getContext());
                            }
                        });

                    }
                }
            } catch (IOException e) {} finally {
                if (httpURLConnection != null) {
                    httpURLConnection.disconnect();
                }
            }
        });
    }
    /******************http构造表单上传销毁指令数据区域***************>*/

    /*<****************http请求全站数据区域*****************/
    public void DownDataWorldListInfo(String type,String field){
        NetManager main_toplistnetmanger = NetManager.getInstance(this.getContext());
        if (!main_toplistnetmanger.hasDefaultNet()) {
            return;
        }
        ThreadPoolUtil.submit(() -> {
            NetHandle thenetHandle = main_toplistnetmanger.getDefaultNet();
            NetStatusCallback netStatusCallback = new NetStatusCallback() {};
            HttpURLConnection httpURLConnection = null;
            String urlString = null;

            switch(type){
                case "worlddt":

                    urlString = DataCenterControl.serverIpWithPort + "worlddt/";
                    break;
                case "worldxm":

                    urlString = DataCenterControl.serverIpWithPort + "worldxm/";
                    break;
                case "worldwz":

                    urlString = DataCenterControl.serverIpWithPort + "worldwz/";
                    break;
                case "worldfield":

                    urlString = DataCenterControl.serverIpWithPort + "worldfield/";
                    break;
                default:

                    urlString = DataCenterControl.serverIpWithPort + "index/";
                    break;
            }

            try {
                URL url = new URL(urlString);
                ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
                URLConnection urlConnection = thenetHandle.openConnection(url, java.net.Proxy.NO_PROXY);
                if (urlConnection instanceof HttpURLConnection) {
                    httpURLConnection = (HttpURLConnection) urlConnection;
                    httpURLConnection.setRequestMethod("POST");
                    httpURLConnection.setDoOutput(true);

                    StringBuilder stringBuilder = new StringBuilder();
                    stringBuilder.append("field_id=");
                    switch (field){
                        case "art":
                            stringBuilder.append("1");
                            break;
                        case "clothe":
                            stringBuilder.append("2");
                            break;
                        case "food":
                            stringBuilder.append("3");
                            break;
                        case "house":
                            stringBuilder.append("4");
                            break;
                        case "traffic":
                            stringBuilder.append("5");
                            break;
                        case "study":
                            stringBuilder.append("6");
                            break;
                        case "culture":
                            stringBuilder.append("7");
                            break;
                        default:
                            stringBuilder.append("0");
                            break;
                    }
                    byte[] b = stringBuilder.toString().getBytes();
                    httpURLConnection.getOutputStream().write(b);

                    try {
                        httpURLConnection.connect();
                    } catch (IOException e) {}
                    outputStream.flush();


                    InputStream inputStream = null;
                    try {
                        inputStream = urlConnection.getInputStream();
                        byte[] cache = new byte[2 * 1024];
                        int len = inputStream.read(cache);
                        while (len != -1) {
                            outputStream.write(cache, 0, len);
                            len = inputStream.read(cache);
                        }
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                    String result = "";
                    result = outputStream.toString();
                    if(result.indexOf("sum") != -1){
                        //请求全站动态成功
                        String finalResult = result;
                        getUITaskDispatcher().asyncDispatch(new Runnable() {
                            @Override
                            public void run() {
                                switch (type) {
                                    case "worlddt":
                                        ZSONObject zsonobject_dt = ZSONObject.stringToZSON(finalResult);
                                        int sum_dt = Integer.parseInt(zsonobject_dt.getString("sum"));
                                        DataCenterControl.worlddt_listcontainer_list.clear();
                                        for(int i = 0;i < sum_dt;i++){
                                            ZSONObject t = ZSONObject.stringToZSON(zsonobject_dt.getString(String.valueOf(i)));

                                            int detail_len = t.getString("DETAIL").length();
                                            DataCenterControl.worlddt_listcontainer_list.add(
                                                    new LCArryListContentItem(t.getString("CONTENT_ID")
                                                                             ,t.getString("TYPE")
                                                                             ,t.getString("DATE")
                                                                             ,t.getString("READVALUE")
                                                                             ,t.getString("DETAIL").substring(12,detail_len - 1 - 1).replace("\\n","\n")
                                                                             ,t.getString("USER_ID")
                                                                             ,DataCenterControl.fields[Integer.parseInt(t.getString("FIELD_ID")) - 1]
                                                                             )
                                                    );
                                        }

                                        if(DataCenterControl.worldDtListContainerProvider != null){
                                            DataCenterControl.worldDtListContainerProvider.notifyDataChanged();
                                        }
                                        MyTools.toastShow("全站动态下载成功！", MainAbilitySlice.this.getContext());
                                        break;
                                    case "worldxm":
                                        ZSONObject zsonobject_xm = ZSONObject.stringToZSON(finalResult);
                                        int sum_xm = Integer.parseInt(zsonobject_xm.getString("sum"));
                                        DataCenterControl.worldxm_listcontainer_list.clear();
                                        for(int i = 0;i < sum_xm;i++){
                                            ZSONObject t = ZSONObject.stringToZSON(zsonobject_xm.getString(String.valueOf(i)));

                                            int detail_len = t.getString("DETAIL").length();
                                            DataCenterControl.worldxm_listcontainer_list.add(
                                                    new LCArryListContentItem(t.getString("CONTENT_ID")
                                                                            ,t.getString("TYPE")
                                                                            ,t.getString("DATE")
                                                                            ,t.getString("READVALUE")
                                                                            ,t.getString("DETAIL")
                                                                            ,t.getString("USER_ID")
                                                                            ,DataCenterControl.fields[Integer.parseInt(t.getString("FIELD_ID")) - 1]
                                                    )
                                            );
                                        }
                                        if(DataCenterControl.worldXmListContainerProvider != null){
                                            DataCenterControl.worldXmListContainerProvider.notifyDataChanged();
                                        }
                                        MyTools.toastShow("全站项目下载成功！", MainAbilitySlice.this.getContext());
                                        break;
                                    case "worldwz":
                                        ZSONObject zsonobject_wz = ZSONObject.stringToZSON(finalResult);
                                        int sum_wz = Integer.parseInt(zsonobject_wz.getString("sum"));
                                        DataCenterControl.worldwz_listcontainer_list.clear();
                                        for(int i = 0;i < sum_wz;i++){
                                            ZSONObject t = ZSONObject.stringToZSON(zsonobject_wz.getString(String.valueOf(i)));

                                            int detail_len = t.getString("DETAIL").length();
                                            DataCenterControl.worldwz_listcontainer_list.add(
                                                    new LCArryListContentItem(t.getString("CONTENT_ID")
                                                                            ,t.getString("TYPE")
                                                                            ,t.getString("DATE")
                                                                            ,t.getString("READVALUE")
                                                                            ,t.getString("DETAIL").substring(12,detail_len - 1 - 1).replace("\\n","\n")
                                                                            ,t.getString("USER_ID")
                                                                            ,DataCenterControl.fields[Integer.parseInt(t.getString("FIELD_ID")) - 1]
                                                    )
                                            );
                                        }
                                        if(DataCenterControl.worldWzListContainerProvider != null){
                                            MyTools.toastShow("动态刷新！",MainAbilitySlice.this.getContext());
                                            DataCenterControl.worldWzListContainerProvider.notifyDataChanged();
                                        }
                                        MyTools.toastShow("全站文章下载成功！", MainAbilitySlice.this.getContext());
                                        break;
                                    case "worldfield":
                                        switch (field){
                                            case "art":
                                                ZSONObject zsonobject_art = ZSONObject.stringToZSON(finalResult);
                                                int sum_art = Integer.parseInt(zsonobject_art.getString("sum"));
                                                DataCenterControl.art_listcontainer_list.clear();
                                                for(int i = 0;i < sum_art;i++){
                                                    ZSONObject t = ZSONObject.stringToZSON(zsonobject_art.getString(String.valueOf(i)));
                                                    String field = t.getString("TYPE");
                                                    int detail_len = t.getString("DETAIL").length();
                                                    if(field.equals("动态") || field.equals("文章")){
                                                        DataCenterControl.art_listcontainer_list.add(
                                                                new LCArryListContentItem(t.getString("CONTENT_ID")
                                                                        ,t.getString("TYPE")
                                                                        ,t.getString("DATE")
                                                                        ,t.getString("READVALUE")
                                                                        ,t.getString("DETAIL").substring(12,detail_len - 1 - 1).replace("\\n","\n")
                                                                        ,t.getString("USER_ID")
                                                                        ,DataCenterControl.fields[Integer.parseInt(t.getString("FIELD_ID")) - 1]
                                                                )
                                                        );
                                                    }
                                                    if(field.equals("项目")){
                                                        DataCenterControl.art_listcontainer_list.add(
                                                                new LCArryListContentItem(t.getString("CONTENT_ID")
                                                                        ,t.getString("TYPE")
                                                                        ,t.getString("DATE")
                                                                        ,t.getString("READVALUE")
                                                                        ,t.getString("DETAIL")
                                                                        ,t.getString("USER_ID")
                                                                        ,DataCenterControl.fields[Integer.parseInt(t.getString("FIELD_ID")) - 1]
                                                                )
                                                        );
                                                    }
                                                }
                                                if(DataCenterControl.artListContainerProvider != null){
                                                    DataCenterControl.artListContainerProvider.notifyDataChanged();
                                                }
                                                MyTools.toastShow("[艺]下载成功！", MainAbilitySlice.this.getContext());
                                                break;
                                            case "clothe":
                                                ZSONObject zsonobject_clothe = ZSONObject.stringToZSON(finalResult);
                                                int sum_clothe = Integer.parseInt(zsonobject_clothe.getString("sum"));
                                                DataCenterControl.clothe_listcontainer_list.clear();
                                                for(int i = 0;i < sum_clothe;i++){
                                                    ZSONObject t = ZSONObject.stringToZSON(zsonobject_clothe.getString(String.valueOf(i)));
                                                    String field = t.getString("TYPE");
                                                    int detail_len = t.getString("DETAIL").length();
                                                    if(field.equals("动态") || field.equals("文章")){
                                                        DataCenterControl.clothe_listcontainer_list.add(
                                                                new LCArryListContentItem(t.getString("CONTENT_ID")
                                                                        ,t.getString("TYPE")
                                                                        ,t.getString("DATE")
                                                                        ,t.getString("READVALUE")
                                                                        ,t.getString("DETAIL").substring(12,detail_len - 1 - 1).replace("\\n","\n")
                                                                        ,t.getString("USER_ID")
                                                                        ,DataCenterControl.fields[Integer.parseInt(t.getString("FIELD_ID")) - 1]
                                                                )
                                                        );
                                                    }
                                                    if(field.equals("项目")){
                                                        DataCenterControl.clothe_listcontainer_list.add(
                                                                new LCArryListContentItem(t.getString("CONTENT_ID")
                                                                        ,t.getString("TYPE")
                                                                        ,t.getString("DATE")
                                                                        ,t.getString("READVALUE")
                                                                        ,t.getString("DETAIL")
                                                                        ,t.getString("USER_ID")
                                                                        ,DataCenterControl.fields[Integer.parseInt(t.getString("FIELD_ID")) - 1]
                                                                )
                                                        );
                                                    }
                                                }

                                                if(DataCenterControl.clotheListContainerProvider != null){
                                                    DataCenterControl.clotheListContainerProvider.notifyDataChanged();
                                                }
                                                MyTools.toastShow("[衣]下载成功！", MainAbilitySlice.this.getContext());
                                                break;
                                            case "food":
                                                ZSONObject zsonobject_food = ZSONObject.stringToZSON(finalResult);
                                                int sum_food = Integer.parseInt(zsonobject_food.getString("sum"));
                                                DataCenterControl.food_listcontainer_list.clear();
                                                for(int i = 0;i < sum_food;i++){
                                                    ZSONObject t = ZSONObject.stringToZSON(zsonobject_food.getString(String.valueOf(i)));
                                                    String field = t.getString("TYPE");
                                                    int detail_len = t.getString("DETAIL").length();
                                                    if(field.equals("动态") || field.equals("文章")){
                                                        DataCenterControl.food_listcontainer_list.add(
                                                                new LCArryListContentItem(t.getString("CONTENT_ID")
                                                                        ,t.getString("TYPE")
                                                                        ,t.getString("DATE")
                                                                        ,t.getString("READVALUE")
                                                                        ,t.getString("DETAIL").substring(12,detail_len - 1 - 1).replace("\\n","\n")
                                                                        ,t.getString("USER_ID")
                                                                        ,DataCenterControl.fields[Integer.parseInt(t.getString("FIELD_ID")) - 1]
                                                                )
                                                        );
                                                    }
                                                    if(field.equals("项目")){
                                                        DataCenterControl.food_listcontainer_list.add(
                                                                new LCArryListContentItem(t.getString("CONTENT_ID")
                                                                        ,t.getString("TYPE")
                                                                        ,t.getString("DATE")
                                                                        ,t.getString("READVALUE")
                                                                        ,t.getString("DETAIL")
                                                                        ,t.getString("USER_ID")
                                                                        ,DataCenterControl.fields[Integer.parseInt(t.getString("FIELD_ID")) - 1]
                                                                )
                                                        );
                                                    }
                                                }

                                                if(DataCenterControl.foodListContainerProvider != null){
                                                    DataCenterControl.foodListContainerProvider.notifyDataChanged();
                                                }
                                                MyTools.toastShow("[食]下载成功！", MainAbilitySlice.this.getContext());
                                                break;
                                            case "house":
                                                ZSONObject zsonobject_house = ZSONObject.stringToZSON(finalResult);
                                                int sum_house = Integer.parseInt(zsonobject_house.getString("sum"));
                                                DataCenterControl.house_listcontainer_list.clear();
                                                for(int i = 0;i < sum_house;i++){
                                                    ZSONObject t = ZSONObject.stringToZSON(zsonobject_house.getString(String.valueOf(i)));
                                                    String field = t.getString("TYPE");
                                                    int detail_len = t.getString("DETAIL").length();
                                                    if(field.equals("动态") || field.equals("文章")){
                                                        DataCenterControl.house_listcontainer_list.add(
                                                                new LCArryListContentItem(t.getString("CONTENT_ID")
                                                                        ,t.getString("TYPE")
                                                                        ,t.getString("DATE")
                                                                        ,t.getString("READVALUE")
                                                                        ,t.getString("DETAIL").substring(12,detail_len - 1 - 1).replace("\\n","\n")
                                                                        ,t.getString("USER_ID")
                                                                        ,DataCenterControl.fields[Integer.parseInt(t.getString("FIELD_ID")) - 1]
                                                                )
                                                        );
                                                    }
                                                    if(field.equals("项目")){
                                                        DataCenterControl.house_listcontainer_list.add(
                                                                new LCArryListContentItem(t.getString("CONTENT_ID")
                                                                        ,t.getString("TYPE")
                                                                        ,t.getString("DATE")
                                                                        ,t.getString("READVALUE")
                                                                        ,t.getString("DETAIL")
                                                                        ,t.getString("USER_ID")
                                                                        ,DataCenterControl.fields[Integer.parseInt(t.getString("FIELD_ID")) - 1]
                                                                )
                                                        );
                                                    }
                                                }

                                                if(DataCenterControl.houseListContainerProvider != null){
                                                    DataCenterControl.houseListContainerProvider.notifyDataChanged();
                                                }
                                                MyTools.toastShow("[住]下载成功！", MainAbilitySlice.this.getContext());
                                                break;
                                            case "traffic":
                                                ZSONObject zsonobject_traffic = ZSONObject.stringToZSON(finalResult);
                                                int sum_traffic = Integer.parseInt(zsonobject_traffic.getString("sum"));
                                                DataCenterControl.traffic_listcontainer_list.clear();
                                                for(int i = 0;i < sum_traffic;i++){
                                                    ZSONObject t = ZSONObject.stringToZSON(zsonobject_traffic.getString(String.valueOf(i)));
                                                    String field = t.getString("TYPE");
                                                    int detail_len = t.getString("DETAIL").length();
                                                    if(field.equals("动态") || field.equals("文章")){
                                                        DataCenterControl.traffic_listcontainer_list.add(
                                                                new LCArryListContentItem(t.getString("CONTENT_ID")
                                                                        ,t.getString("TYPE")
                                                                        ,t.getString("DATE")
                                                                        ,t.getString("READVALUE")
                                                                        ,t.getString("DETAIL").substring(12,detail_len - 1 - 1).replace("\\n","\n")
                                                                        ,t.getString("USER_ID")
                                                                        ,DataCenterControl.fields[Integer.parseInt(t.getString("FIELD_ID")) - 1]
                                                                )
                                                        );
                                                    }
                                                    if(field.equals("项目")){
                                                        DataCenterControl.traffic_listcontainer_list.add(
                                                                new LCArryListContentItem(t.getString("CONTENT_ID")
                                                                        ,t.getString("TYPE")
                                                                        ,t.getString("DATE")
                                                                        ,t.getString("READVALUE")
                                                                        ,t.getString("DETAIL")
                                                                        ,t.getString("USER_ID")
                                                                        ,DataCenterControl.fields[Integer.parseInt(t.getString("FIELD_ID")) - 1]
                                                                )
                                                        );
                                                    }
                                                }

                                                if(DataCenterControl.trafficListContainerProvider != null){
                                                    DataCenterControl.trafficListContainerProvider.notifyDataChanged();
                                                }
                                                MyTools.toastShow("[行]下载成功！", MainAbilitySlice.this.getContext());
                                                break;
                                            case "study":
                                                ZSONObject zsonobject_study = ZSONObject.stringToZSON(finalResult);
                                                int sum_study = Integer.parseInt(zsonobject_study.getString("sum"));
                                                DataCenterControl.study_listcontainer_list.clear();
                                                for(int i = 0;i < sum_study;i++){
                                                    ZSONObject t = ZSONObject.stringToZSON(zsonobject_study.getString(String.valueOf(i)));
                                                    String field = t.getString("TYPE");
                                                    int detail_len = t.getString("DETAIL").length();
                                                    if(field.equals("动态") || field.equals("文章")){
                                                        DataCenterControl.study_listcontainer_list.add(
                                                                new LCArryListContentItem(t.getString("CONTENT_ID")
                                                                        ,t.getString("TYPE")
                                                                        ,t.getString("DATE")
                                                                        ,t.getString("READVALUE")
                                                                        ,t.getString("DETAIL").substring(12,detail_len - 1 - 1).replace("\\n","\n")
                                                                        ,t.getString("USER_ID")
                                                                        ,DataCenterControl.fields[Integer.parseInt(t.getString("FIELD_ID")) - 1]
                                                                )
                                                        );
                                                    }
                                                    if(field.equals("项目")){
                                                        DataCenterControl.study_listcontainer_list.add(
                                                                new LCArryListContentItem(t.getString("CONTENT_ID")
                                                                        ,t.getString("TYPE")
                                                                        ,t.getString("DATE")
                                                                        ,t.getString("READVALUE")
                                                                        ,t.getString("DETAIL")
                                                                        ,t.getString("USER_ID")
                                                                        ,DataCenterControl.fields[Integer.parseInt(t.getString("FIELD_ID")) - 1]
                                                                )
                                                        );
                                                    }
                                                }

                                                if(DataCenterControl.studyListContainerProvider != null){
                                                    DataCenterControl.studyListContainerProvider.notifyDataChanged();
                                                }
                                                MyTools.toastShow("[学]下载成功！", MainAbilitySlice.this.getContext());
                                                break;
                                            case "culture":
                                                ZSONObject zsonobject_culture = ZSONObject.stringToZSON(finalResult);
                                                int sum_culture = Integer.parseInt(zsonobject_culture.getString("sum"));
                                                DataCenterControl.culture_listcontainer_list.clear();
                                                for(int i = 0;i < sum_culture;i++){
                                                    ZSONObject t = ZSONObject.stringToZSON(zsonobject_culture.getString(String.valueOf(i)));
                                                    String field = t.getString("TYPE");
                                                    int detail_len = t.getString("DETAIL").length();
                                                    if(field.equals("动态") || field.equals("文章")){
                                                        DataCenterControl.culture_listcontainer_list.add(
                                                                new LCArryListContentItem(t.getString("CONTENT_ID")
                                                                        ,t.getString("TYPE")
                                                                        ,t.getString("DATE")
                                                                        ,t.getString("READVALUE")
                                                                        ,t.getString("DETAIL").substring(12,detail_len - 1 - 1).replace("\\n","\n")
                                                                        ,t.getString("USER_ID")
                                                                        ,DataCenterControl.fields[Integer.parseInt(t.getString("FIELD_ID")) - 1]
                                                                )
                                                        );
                                                    }
                                                    if(field.equals("项目")){
                                                        DataCenterControl.culture_listcontainer_list.add(
                                                                new LCArryListContentItem(t.getString("CONTENT_ID")
                                                                        ,t.getString("TYPE")
                                                                        ,t.getString("DATE")
                                                                        ,t.getString("READVALUE")
                                                                        ,t.getString("DETAIL")
                                                                        ,t.getString("USER_ID")
                                                                        ,DataCenterControl.fields[Integer.parseInt(t.getString("FIELD_ID")) - 1]
                                                                )
                                                        );
                                                    }
                                                }
                                                if(DataCenterControl.cultureListContainerProvider != null){
                                                    DataCenterControl.cultureListContainerProvider.notifyDataChanged();
                                                }
                                                MyTools.toastShow("[文]下载成功！", MainAbilitySlice.this.getContext());
                                                break;
                                            default:
                                                break;
                                        }
                                        break;
                                    default:
                                        MyTools.toastShow("全站未知下载成功！", MainAbilitySlice.this.getContext());
                                        break;
                                }
                            }
                        });
                    }
                    else if(result.equals("NULL")){
                        getUITaskDispatcher().asyncDispatch(new Runnable() {
                            @Override
                            public void run() {
                                MyTools.toastShow("全站内容为空！", MainAbilitySlice.this.getContext());
                            }
                        });
                    }
                    else{
                        getUITaskDispatcher().asyncDispatch(new Runnable() {
                            @Override
                            public void run() {
                                switch (type) {
                                    case "worlddt":
                                        MyTools.toastShow("全站动态下载失败！", MainAbilitySlice.this.getContext());
                                        break;
                                    case "worldxm":
                                        MyTools.toastShow("全站项目下载失败！", MainAbilitySlice.this.getContext());
                                        break;
                                    case "worldwz":
                                        MyTools.toastShow("全站文章下载失败！", MainAbilitySlice.this.getContext());
                                        break;
                                    default:
                                        MyTools.toastShow("全站未知下载失败！", MainAbilitySlice.this.getContext());
                                        break;
                                }
                            }
                        });
                    }
                }
            } catch (IOException e) {} finally {
                if (httpURLConnection != null) {
                    httpURLConnection.disconnect();
                }
            }
        });
    }
    /******************http请求全站数据区域***************>*/

    /*<****************http请求用户点赞、评论、收藏消息数据区域*****************/
    public void DownDataMessageListInfo(String type){
        NetManager main_toplistnetmanger = NetManager.getInstance(this.getContext());
        if (!main_toplistnetmanger.hasDefaultNet()) {
            return;
        }
        ThreadPoolUtil.submit(() -> {
            NetHandle thenetHandle = main_toplistnetmanger.getDefaultNet();
            NetStatusCallback netStatusCallback = new NetStatusCallback() {};
            HttpURLConnection httpURLConnection = null;

            String urlString = DataCenterControl.serverIpWithPort + "message/?";

            try {
                URL url = new URL(urlString);
                ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
                URLConnection urlConnection = thenetHandle.openConnection(url, java.net.Proxy.NO_PROXY);
                if (urlConnection instanceof HttpURLConnection) {
                    httpURLConnection = (HttpURLConnection) urlConnection;
                    httpURLConnection.setRequestMethod("POST");
                    httpURLConnection.setDoOutput(true);

                    StringBuilder stringBuilder = new StringBuilder();
                    stringBuilder.append("username=");
                    stringBuilder.append(DataCenterControl.userName);
                    stringBuilder.append("&messagetype=");
                    switch(type){
                        case "messageagree":
                            stringBuilder.append("AGREE");
                            break;
                        case "messagediscuss":
                            stringBuilder.append("DISCUSS");
                            break;
                        case "messagecollect":
                            stringBuilder.append("COLLECT");
                            break;
                        default:
                            break;
                    }

                    byte[] b = stringBuilder.toString().getBytes();
                    httpURLConnection.getOutputStream().write(b);

                    try {
                        httpURLConnection.connect();
                    } catch (IOException e) {}
                    outputStream.flush();


                    InputStream inputStream = null;
                    try {
                        inputStream = urlConnection.getInputStream();
                        byte[] cache = new byte[2 * 1024];
                        int len = inputStream.read(cache);
                        while (len != -1) {
                            outputStream.write(cache, 0, len);
                            len = inputStream.read(cache);
                        }
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                    String result = "";
                    result = outputStream.toString();
                    //System.out.println("---httpURLConnection>>>>" + result);
                    if(result.indexOf("sum") != -1){
                        //请求全站动态成功
                        String finalResult = result;
                        getUITaskDispatcher().asyncDispatch(new Runnable() {
                            @Override
                            public void run() {
                                switch (type) {
                                    case "messageagree":
                                        ZSONObject zsonobject_agree = ZSONObject.stringToZSON(finalResult);
                                        int sum_agree = Integer.parseInt(zsonobject_agree.getString("sum"));
                                        DataCenterControl.messageagree_listcontainer_list.clear();
                                        for(int i = 0;i < sum_agree;i++){
                                            String info = zsonobject_agree.getString(String.valueOf(i));
                                            DataCenterControl.messageagree_listcontainer_list.add(new LCArryListNormalItem(info));
                                        }
                                        if(DataCenterControl.messageAgreeListContainerProvider != null){
                                            DataCenterControl.messageAgreeListContainerProvider.notifyDataChanged();
                                        }
                                        MyTools.toastShow("用户点赞消息下载成功！", MainAbilitySlice.this.getContext());
                                        break;
                                    case "messagediscuss":
                                        ZSONObject zsonobject_discuss = ZSONObject.stringToZSON(finalResult);
                                        int sum_discuss = Integer.parseInt(zsonobject_discuss.getString("sum"));
                                        DataCenterControl.messagediscuss_listcontainer_list.clear();
                                        for(int i = 0;i < sum_discuss;i++){
                                            String info = zsonobject_discuss.getString(String.valueOf(i));
                                            DataCenterControl.messagediscuss_listcontainer_list.add(new LCArryListNormalItem(info));
                                        }
                                        if(DataCenterControl.messageDiscussListContainerProvider != null){
                                            DataCenterControl.messageDiscussListContainerProvider.notifyDataChanged();
                                        }
                                        MyTools.toastShow("用户评论消息下载成功！", MainAbilitySlice.this.getContext());
                                        break;
                                    case "messagecollect":
                                        ZSONObject zsonobject_collect = ZSONObject.stringToZSON(finalResult);
                                        int sum_collect = Integer.parseInt(zsonobject_collect.getString("sum"));
                                        DataCenterControl.messagecollect_listcontainer_list.clear();
                                        for(int i = 0;i < sum_collect;i++){
                                            String info = zsonobject_collect.getString(String.valueOf(i));
                                            DataCenterControl.messagecollect_listcontainer_list.add(new LCArryListNormalItem(info));
                                        }
                                        if(DataCenterControl.messageCollectListContainerProvider != null){
                                            DataCenterControl.messageCollectListContainerProvider.notifyDataChanged();
                                        }
                                        MyTools.toastShow("用户收藏消息下载成功！", MainAbilitySlice.this.getContext());
                                        break;
                                    default:
                                        MyTools.toastShow("全站未知下载成功！", MainAbilitySlice.this.getContext());
                                        break;
                                }
                            }
                        });
                    }
                    else if(result.equals("NULL")){
                        getUITaskDispatcher().asyncDispatch(new Runnable() {
                            @Override
                            public void run() {
                                switch (type) {
                                    case "messageagree":
                                        DataCenterControl.messageagree_listcontainer_list.clear();
                                        if(DataCenterControl.messageAgreeListContainerProvider != null){
                                            DataCenterControl.messageAgreeListContainerProvider.notifyDataChanged();
                                        }
                                        break;
                                    case "messagediscuss":
                                        DataCenterControl.messagediscuss_listcontainer_list.clear();
                                        if(DataCenterControl.messageDiscussListContainerProvider != null){
                                            DataCenterControl.messageDiscussListContainerProvider.notifyDataChanged();
                                        }
                                        break;
                                    case "messagecollect":
                                        DataCenterControl.messagecollect_listcontainer_list.clear();
                                        if(DataCenterControl.messageCollectListContainerProvider != null){
                                            DataCenterControl.messageCollectListContainerProvider.notifyDataChanged();
                                        }
                                        break;
                                }
                                MyTools.toastShow("用户消息为空！", MainAbilitySlice.this.getContext());
                            }
                        });
                    }
                    else{
                        getUITaskDispatcher().asyncDispatch(new Runnable() {
                            @Override
                            public void run() {
                                switch (type) {
                                    case "messageagree":
                                        MyTools.toastShow("用户点赞消息下载失败！", MainAbilitySlice.this.getContext());
                                        break;
                                    case "messagediscuss":
                                        MyTools.toastShow("用户评论消息下载失败！", MainAbilitySlice.this.getContext());
                                        break;
                                    case "messagecollect":
                                        MyTools.toastShow("用户收藏下载失败！", MainAbilitySlice.this.getContext());
                                        break;
                                    default:
                                        MyTools.toastShow("用户未知消息下载失败！", MainAbilitySlice.this.getContext());
                                        break;
                                }
                            }
                        });
                    }
                }
            } catch (IOException e) {
            } finally {
                if (httpURLConnection != null) {
                    httpURLConnection.disconnect();
                }
            }
        });
    }
    /******************http请求用户点赞、评论、收藏消息数据区域***************>*/

    /*<****************htt请求关注数目、粉丝数目、阅读数目数据区域*****************/
    public void DownDataFollowFansReadvalueInfo(String username,Text[] followfansread){
        NetManager main_toplistnetmanger = NetManager.getInstance(this.getContext());
        if (!main_toplistnetmanger.hasDefaultNet()) {
            return;
        }
        ThreadPoolUtil.submit(() -> {
            NetHandle thenetHandle = main_toplistnetmanger.getDefaultNet();
            NetStatusCallback netStatusCallback = new NetStatusCallback() {};
            HttpURLConnection httpURLConnection = null;

            String urlString = DataCenterControl.serverIpWithPort + "count/?";
            try {
                URL url = new URL(urlString);

                ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
                URLConnection urlConnection = thenetHandle.openConnection(url, java.net.Proxy.NO_PROXY);
                if (urlConnection instanceof HttpURLConnection) {
                    httpURLConnection = (HttpURLConnection) urlConnection;

                    httpURLConnection.setRequestMethod("POST");
                    httpURLConnection.setDoOutput(true);

                    StringBuilder stringBuilder = new StringBuilder();

                    stringBuilder.append("username");
                    stringBuilder.append("=");
                    stringBuilder.append(username);

                    byte[] b = stringBuilder.toString().getBytes();
                    httpURLConnection.getOutputStream().write(b);

                    try {
                        httpURLConnection.connect();
                    } catch (IOException e) {}
                    outputStream.flush();


                    InputStream inputStream = null;
                    try {
                        inputStream = urlConnection.getInputStream();
                        byte[] cache = new byte[2 * 1024];
                        int len = inputStream.read(cache);
                        while (len != -1) {
                            outputStream.write(cache, 0, len);
                            len = inputStream.read(cache);
                        }
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                    String result = "";
                    result = outputStream.toString();
                    if(result.startsWith("OK")){
                        String[] numbers = result.substring(3).split(",");
                        if(followfansread != null){
                            getUITaskDispatcher().asyncDispatch(new Runnable() {
                                @Override
                                public void run() {
                                    followfansread[0].setText(numbers[0]);
                                    followfansread[1].setText(numbers[1]);
                                    followfansread[2].setText(numbers[2]);
                                }
                            });
                        }
                    }
                    else{
                        getUITaskDispatcher().asyncDispatch(new Runnable() {
                            @Override
                            public void run() {
                                MyTools.toastShow("计数请求失败", MainAbilitySlice.this.getContext());
                            }
                        });

                    }
                }
            } catch (IOException e) {

            } finally {
                if (httpURLConnection != null) {
                    httpURLConnection.disconnect();
                }
            }
        });
    }
    /******************htt请求关注数目、粉丝数目、阅读数目数据区域***************>*/




    /*<-----------------------------------------安装顶部子布局区域-----------------------------------*/
    public void installSearchBar(){
        //安装搜索栏——将搜索栏安装到首页的顶部区域
        final int[] deepdl_topdl_height = {0};
        final boolean[] iskeyboarduse = {false};
        if(deepdl_topdl == null){
            return;
        }
        if(deepdl_topdl.getChildCount() != 0){
            deepdl_topdl.removeAllComponents();
        }
        DirectionalLayout searchbar_rootdl = (DirectionalLayout) LayoutScatter
                                            .getInstance(this.getContext())
                                            .parse(ResourceTable.Layout_searchbar,null,true);
        TextField searchtextField = (TextField) searchbar_rootdl.getComponentAt(0);
        Text searchGo = (Text) searchbar_rootdl.getComponentAt(1);

        searchtextField.addTextObserver(new Text.TextObserver() {
            @Override
            public void onTextUpdated(String s, int i, int i1, int i2) {

            }
        });
        searchGo.setClickedListener(new Component.ClickedListener() {
            @Override
            public void onClick(Component component) {
                searchtextField.clearFocus();
                present(new PeopleListSlice(),new Intent().setParam("objectname", searchtextField.getText()));
            }
        });
        deepdl_topdl.setLayoutRefreshedListener(new Component.LayoutRefreshedListener() {
            @Override
            public void onRefreshed(Component component) {
                if(deepdl_topdl_height[0] == 0){
                    deepdl_topdl_height[0] = deepdl_topdl.getHeight();
                    return;
                }
                if(deepdl_topdl.getHeight() < deepdl_topdl_height[0]){
                    iskeyboarduse[0] = true;
                }
                if(deepdl_topdl.getHeight() == deepdl_topdl_height[0] && iskeyboarduse[0]){
                    searchtextField.clearFocus();
                    iskeyboarduse[0] = false;
                }
            }
        });
        deepdl_topdl.addComponent(searchbar_rootdl);
    }
    public void installTitleBar(String titleName){
        //安装标题栏——当底部导航栏切换到领域、消息、我的时安装，只安装一次，只需更改title文字内容即可
        if(deepdl_topdl == null){
            return;
        }
        if(deepdl_topdl.getChildCount() != 0){
            DirectionalLayout topsublayout_rootdl = (DirectionalLayout) deepdl_topdl.getComponentAt(0);
            if(topsublayout_rootdl.getChildCount() == 2){
                deepdl_topdl.removeAllComponents();
            }
            else{
                ((Text) topsublayout_rootdl.getComponentAt(0)).setText(titleName);
                return;
            }
        }
        DirectionalLayout titlebar_rootdl = (DirectionalLayout) LayoutScatter
                                            .getInstance(this.getContext())
                                            .parse(ResourceTable.Layout_main_titlebar,null,false);
        ((Text) titlebar_rootdl.getComponentAt(0)).setText(titleName);
        deepdl_topdl.addComponent(titlebar_rootdl);
    }
    public void installTopSubLayout(TabList.Tab tab){
        //安装顶部区域子布局
        switch (tab.getPosition()){
            case 0:
                installSearchBar();
                return;
            case 1:
            case 3:
            case 4:
                installTitleBar(tab.getText());
                return;
            default:
                return;
        }
    }
    /*------------------------------------------安装顶部子布局区域---------------------------------->*/

    /*<-----------------------------------------安装中部子布局区域-----------------------------------*/
    public Component installCenterSubLayout(TabList.Tab tab){
        //安装中间区域子布局
        //0-首页，1-L领域，2-➕，3-消息，4-我的
        if(deepdl_centerdl == null){
            return null;
        }
        if(deepdl_centerdl.getChildCount() != 0){
            deepdl_centerdl.removeAllComponents();
        }
        switch (tab.getPosition()){
            case 0:
                DirectionalLayout firstpage_center_rootdl = (DirectionalLayout) LayoutScatter
                                                            .getInstance(this.getContext())
                                                            .parse(ResourceTable.Layout_firstpage_center,null,false);
                deepdl_centerdl.addComponent(firstpage_center_rootdl);
                return firstpage_center_rootdl;
            case 1:
                DirectionalLayout secondpage_center_rootdl = (DirectionalLayout) LayoutScatter
                                                            .getInstance(this.getContext())
                                                            .parse(ResourceTable.Layout_firstpage_center,null,false);
                deepdl_centerdl.addComponent(secondpage_center_rootdl);
                return secondpage_center_rootdl;
            case 2:
                //这是bottomtablist的“+”位置，不做安装中间布局的处理
                return null;

            case 3:
                DirectionalLayout fourthpage_center_rootdl = (DirectionalLayout) LayoutScatter
                                                            .getInstance(this.getContext())
                                                            .parse(ResourceTable.Layout_fourthpage_center,null,false);
                deepdl_centerdl.addComponent(fourthpage_center_rootdl);
                return fourthpage_center_rootdl;
            case 4:
                DirectionalLayout fifthhpage_center_rootdl = (DirectionalLayout) LayoutScatter
                        .getInstance(this.getContext())
                        .parse(ResourceTable.Layout_fifhpage_center,null,false);
                deepdl_centerdl.addComponent(fifthhpage_center_rootdl);
                return fifthhpage_center_rootdl;
            default:
                return null;
        }
    }
    /*------------------------------------------安装中部子布局区域---------------------------------->*/

    /*<-----------------------------------------初始化PageSlider区域-----------------------------------*/
    private void initPageSlider(PageSlider pageSlider,PageSliderProvider pageSliderProvider,TabList bindTabList){
        if(pageSlider == null){
            return;
        }
        pageSlider.setPageCacheSize(3);
        pageSlider.setPageSwitchTime(50);
        pageSlider.setReboundEffect(true);
        pageSlider.setSlidingPossible(true);
        if(pageSliderProvider != null){
            pageSlider.setProvider(pageSliderProvider);
        }
        pageSlider.addPageChangedListener(new PageSlider.PageChangedListener() {
            @Override
            public void onPageSliding(int i, float v, int i1) {

            }

            @Override
            public void onPageSlideStateChanged(int i) {

            }

            @Override
            public void onPageChosen(int i) {
                if(bindTabList != null){
                    bindTabList.selectTabAt(i);
                }
                if(bindTabList.getName().equals("fourthCenterTabList") && i == 0){
                    MyTools.toastShow("通知加载中...",MainAbilitySlice.this.getContext());
                    DataCenterControl.webView.load(DataCenterControl.messageNoticeUrlString);
                }
                if(bindTabList.getName().equals("firstCenterTabList")){
                    switch (i) {
                        case 0:
                            if(worlddownonce[0]){
                                worlddownonce[0] = false;
                            }
                            else{
                                DownDataWorldListInfo("worlddt","");
                                worlddownonce[0] = true;
                            }
                            break;
                        case 1:
                            if(worlddownonce[1]){
                                worlddownonce[1] = false;
                            }
                            else{
                                DownDataWorldListInfo("worldxm","");
                                worlddownonce[1] = true;
                            }
                            break;
                        case 2:
                            if(worlddownonce[2]){
                                worlddownonce[2] = false;
                            }
                            else{
                                DownDataWorldListInfo("worldwz","");
                                worlddownonce[2] = true;
                            }
                            break;
                        default:
                            break;
                    }
                }
                if(bindTabList.getName().equals("secondCenterTabList")){
                    switch (i) {
                        case 0:
                            if(worldfieldonce[0]){
                                worldfieldonce[0] = false;
                            }
                            else{
                                DownDataWorldListInfo("worldfield","art");
                                worldfieldonce[0] = true;
                            }
                            break;
                        case 1:
                            if(worldfieldonce[1]){
                                worldfieldonce[1] = false;
                            }
                            else{
                                DownDataWorldListInfo("worldfield","clothe");
                                worldfieldonce[1] = true;
                            }
                            break;
                        case 2:
                            if(worldfieldonce[2]){
                                worldfieldonce[2] = false;
                            }
                            else{
                                DownDataWorldListInfo("worldfield","food");
                                worldfieldonce[2] = true;
                            }
                            break;
                        case 3:
                            if(worldfieldonce[3]){
                                worldfieldonce[3] = false;
                            }
                            else{
                                DownDataWorldListInfo("worldfield","house");
                                worldfieldonce[3] = true;
                            }
                            break;
                        case 4:
                            if(worldfieldonce[4]){
                                worldfieldonce[4] = false;
                            }
                            else{
                                DownDataWorldListInfo("worldfield","traffic");
                                worldfieldonce[4] = true;
                            }
                            break;
                        case 5:
                            if(worldfieldonce[5]){
                                worldfieldonce[5] = false;
                            }
                            else{
                                DownDataWorldListInfo("worldfield","study");
                                worldfieldonce[5] = true;
                            }
                            break;
                        case 6:
                            if(worldfieldonce[6]){
                                worldfieldonce[6] = false;
                            }
                            else{
                                DownDataWorldListInfo("worldfield","culture");
                                worldfieldonce[6] = true;
                            }
                            break;
                        default:
                            break;
                    }
                }
                if(bindTabList.getName().equals("fourthCenterTabList") && i != 0){
                    switch(i){
                        case 0:
                            DataCenterControl.webView.load(DataCenterControl.messageNoticeUrlString);
                            break;
                        case 1:
                            if(messageonce[0] == true){
                                messageonce[0] = false;
                            }
                            else{
                                DownDataMessageListInfo("messageagree");
                                messageonce[0] = true;
                            }
                            break;
                        case 2:
                            if(messageonce[1] == true){
                                messageonce[1] = false;
                            }
                            else{
                                DownDataMessageListInfo("messagediscuss");
                                messageonce[1] = true;
                            }
                            break;
                        case 3:
                            if(messageonce[2] == true){
                                messageonce[2] = false;
                            }
                            else{
                                DownDataMessageListInfo("messagecollect");
                                messageonce[2] = true;
                            }
                            break;
                        default:
                            break;
                    }
                }

            }
        });
        if(pageSlider.getChildCount() != 0){
            pageSlider.setCurrentPage(0,true);
        }
    }
    /*------------------------------------------初始化PageSlider区域---------------------------------->*/

    /*<-----------------------------------------初始化TabList区域-----------------------------------*/
    private void addTabToTabList(TabList tabList,String tabName,String tabListName){
        //向某个TabList组件中添加一个tab,设置该tab名称
        if(tabList == null){
            return;
        }
        TabList.Tab tab = tabList.new Tab(this.getContext());
        tab.setText(tabName);
        tabList.addTab(tab);
    }
    private void initTabList(TabList tabList, String[] tabNames, String tabListName, PageSlider bindPageSlider){
        //初始化TabList————向里面添加多个tab，并对该tablist设置选择监听器
        if(tabList == null){
            return;
        }
        if(tabList.getTabCount() != 0){
            tabList.removeAllComponents();
        }
        tabList.setName(tabListName);
        for(int i = 0;i < tabNames.length;i++){
            addTabToTabList(tabList,tabNames[i],tabListName);
        }
        tabList.addTabSelectedListener(new TabList.TabSelectedListener() {
            @Override
            public void onSelected(TabList.Tab tab) {
                switch(tabList.getName()){
                    case "mainBottomTablist":
                        ShapeElement shapeElement = new ShapeElement();
                        shapeElement.setRgbColor(new RgbColor(238,149,114));
                        shapeElement.setCornerRadius(35);
                        tab.setBackground(shapeElement);

                        installTopSubLayout(tab);//如果是首页，则安装搜索栏，其余位安装标题栏
                        Component component = installCenterSubLayout(tab);//根据底部的tab安装相应的中间子布局


                        switch(tab.getPosition()){
                            case 0:
                                for(int i = 0;i < worlddownonce.length;i++){
                                    worlddownonce[i] = false;
                                }
                                DataCenterControl.webView = null;
                                //当切换到首页时，初始化中间区域的tablist
                                TabList firstpage_center_rootdl_tablist = (TabList) ((DirectionalLayout) component).getComponentAt(0);
                                PageSlider firstpage_center_rootdl_PageSlider = (PageSlider) ((DirectionalLayout) component).getComponentAt(1);

                                initPageSlider(firstpage_center_rootdl_PageSlider,
                                        new PSProvider(MainAbilitySlice.this, DataCenterControl.firstcenter_pageslist,firstCenterTabNames.length,0),
                                        firstpage_center_rootdl_tablist);
                                initTabList(firstpage_center_rootdl_tablist,
                                        firstCenterTabNames,
                                        "firstCenterTabList",
                                        firstpage_center_rootdl_PageSlider);
                                break;
                            case 1:
                                DataCenterControl.webView = null;
                                //当切换到领域时，初始化中间区域的tablist
                                TabList secondpage_center_rootdl_tablist = (TabList) ((DirectionalLayout) component).getComponentAt(0);
                                PageSlider secondpage_center_rootdl_PageSlider = (PageSlider) ((DirectionalLayout) component).getComponentAt(1);
                                initPageSlider(secondpage_center_rootdl_PageSlider,
                                        new PSProvider(MainAbilitySlice.this, DataCenterControl.secondcenter_pageslist,secondCenterTabNames.length,1),
                                        secondpage_center_rootdl_tablist);
                                initTabList(secondpage_center_rootdl_tablist,
                                        secondCenterTabNames,
                                        "secondCenterTabList",
                                        secondpage_center_rootdl_PageSlider);
                                break;
                            case 2:
                                break;
                            case 3:
                                //当切换到消息时，初始化中间区域的tablist
                                TabList fourthpage_center_rootdl_tablist = (TabList) ((DirectionalLayout) component).getComponentAt(0);
                                PageSlider fourthpage_center_rootdl_PageSlider = (PageSlider) ((DirectionalLayout) component).getComponentAt(1);
                                initPageSlider(fourthpage_center_rootdl_PageSlider,
                                        new PSProvider(MainAbilitySlice.this, DataCenterControl.fourthcenter_pageslist,fourthCenterTabNames.length,3),
                                        fourthpage_center_rootdl_tablist);
                                initTabList(fourthpage_center_rootdl_tablist,
                                        fourthCenterTabNames,
                                        "fourthCenterTabList",
                                        fourthpage_center_rootdl_PageSlider);
                                if(DataCenterControl.webView != null){}
                                break;
                            case 4:
                                //切换到我的
                                DataCenterControl.webView = null;
                                DirectionalLayout fifthhpage_center_rootdl = (DirectionalLayout) component;

                                DirectionalLayout follow_dl = (DirectionalLayout) fifthhpage_center_rootdl.findComponentById(ResourceTable.Id_follow_dl);
                                DirectionalLayout fans_dl = (DirectionalLayout) fifthhpage_center_rootdl.findComponentById(ResourceTable.Id_fans_dl);
                                DirectionalLayout dtlist_dl = (DirectionalLayout) fifthhpage_center_rootdl.findComponentById(ResourceTable.Id_dtlist_dl);
                                DirectionalLayout xmlist_dl = (DirectionalLayout)  fifthhpage_center_rootdl.findComponentById(ResourceTable.Id_xmlist_dl);
                                DirectionalLayout wzlist_dl = (DirectionalLayout)  fifthhpage_center_rootdl.findComponentById(ResourceTable.Id_wzlist_dl);
                                DirectionalLayout collectlist_dl = (DirectionalLayout)  fifthhpage_center_rootdl.findComponentById(ResourceTable.Id_collectlist_dl);
                                DirectionalLayout about_dl = (DirectionalLayout) fifthhpage_center_rootdl.findComponentById(ResourceTable.Id_about_dl);

                                Text username_text = (Text) fifthhpage_center_rootdl.findComponentById(ResourceTable.Id_username_text);
                                Text follow_text = (Text) fifthhpage_center_rootdl.findComponentById(ResourceTable.Id_follow_text);
                                Text fans_text = (Text) fifthhpage_center_rootdl.findComponentById(ResourceTable.Id_fans_text);
                                Text readvalue_text = (Text) fifthhpage_center_rootdl.findComponentById(ResourceTable.Id_readvalue_text);
                                Text age_text = (Text) fifthhpage_center_rootdl.findComponentById(ResourceTable.Id_age_text);
                                Text gender_text = (Text) fifthhpage_center_rootdl.findComponentById(ResourceTable.Id_gender_text);

                                username_text.setText(DataCenterControl.userName);
                                age_text.setText(DataCenterControl.age);
                                gender_text.setText(DataCenterControl.gender);

                                Text[] followfansread = {follow_text,fans_text,readvalue_text};
                                DownDataFollowFansReadvalueInfo(DataCenterControl.userName,followfansread);

                                follow_dl.setClickedListener(new Component.ClickedListener() {
                                    @Override
                                    public void onClick(Component component) {
                                        present(new FollowAndFansListSlice(),new Intent().setParam("type","followlist"));
                                    }
                                });
                                fans_dl.setClickedListener(new Component.ClickedListener() {
                                    @Override
                                    public void onClick(Component component) {
                                        present(new FollowAndFansListSlice(),new Intent().setParam("type","fanslist"));
                                    }
                                });
                                dtlist_dl.setClickedListener(new Component.ClickedListener() {
                                    @Override
                                    public void onClick(Component component) {
                                        present(new UserContentListSlice(),new Intent().setParam("type","dtlist"));
                                    }
                                });
                                xmlist_dl.setClickedListener(new Component.ClickedListener() {
                                    @Override
                                    public void onClick(Component component) {
                                        present(new UserContentListSlice(),new Intent().setParam("type","xmlist"));
                                    }
                                });
                                wzlist_dl.setClickedListener(new Component.ClickedListener() {
                                    @Override
                                    public void onClick(Component component) {
                                        present(new UserContentListSlice(),new Intent().setParam("type","wzlist"));
                                    }
                                });
                                collectlist_dl.setClickedListener(new Component.ClickedListener() {
                                    @Override
                                    public void onClick(Component component) {
                                        present(new UserContentListSlice(),new Intent().setParam("type","collectlist"));
                                    }
                                });
                                fifthhpage_center_rootdl.findComponentById(ResourceTable.Id_quit_dl)
                                        .setClickedListener(new Component.ClickedListener() {
                                            @Override
                                            public void onClick(Component component) {
                                                        DataCenterControl.messageagree_listcontainer_list.clear();
                                                        DataCenterControl.messagediscuss_listcontainer_list.clear();
                                                        DataCenterControl.messagecollect_listcontainer_list.clear();
                                                        DataCenterControl.userdt_listcontainer_list.clear();
                                                        DataCenterControl.userxm_listcontainer_list.clear();
                                                        DataCenterControl.userwz_listcontainer_list.clear();
                                                        DataCenterControl.usercollect_listcontainer_list.clear();
                                                        present(new StartPage(),new Intent());
                                                        terminate();
                                                    }
                                        });
                                fifthhpage_center_rootdl.findComponentById(ResourceTable.Id_destory_dl)
                                        .setClickedListener(new Component.ClickedListener() {
                                            @Override
                                            public void onClick(Component component) {
                                                MyTools.commonDialogRemoveShow("账号销毁提醒"
                                                                                ,"确认销毁账号？"
                                                                                ,component
                                                                                ,-1
                                                                                ,MainAbilitySlice.this
                                                                                ,"destory");

                                            }
                                        });
                                about_dl.setClickedListener(new Component.ClickedListener() {
                                    @Override
                                    public void onClick(Component component) {
                                        present(new AboutDetails(),new Intent());
                                    }
                                });
                                break;
                            default:
                                break;
                        }
                        break;
                    case "firstCenterTabList":
                        switch (tab.getPosition()) {
                            case 0:
                                if(worlddownonce[0]){
                                    worlddownonce[0] = false;
                                }
                                else{
                                    DownDataWorldListInfo("worlddt","");
                                    worlddownonce[0] = true;
                                }
                                break;
                            case 1:
                                if(worlddownonce[1]){
                                    worlddownonce[1] = false;
                                }
                                else{
                                    DownDataWorldListInfo("worldxm","");
                                    worlddownonce[1] = true;
                                }
                                break;
                            case 2:
                                if(worlddownonce[2]){
                                    worlddownonce[2] = false;
                                }
                                else{
                                    DownDataWorldListInfo("worldwz","");
                                    worlddownonce[2] = true;
                                }
                                break;
                            default:
                                break;
                        }
                        if(bindPageSlider != null){
                            bindPageSlider.setCurrentPage(tabList.getSelectedTabIndex(), true);
                        }
                        break;
                    case "secondCenterTabList":
                        switch (tab.getPosition()) {
                            case 0:
                                if(worldfieldonce[0]){
                                    worldfieldonce[0] = false;
                                }
                                else{
                                    DownDataWorldListInfo("worldfield","art");
                                    worldfieldonce[0] = true;
                                }
                                break;
                            case 1:
                                if(worldfieldonce[1]){
                                    worldfieldonce[1] = false;
                                }
                                else{
                                    DownDataWorldListInfo("worldfield","clothe");
                                    worldfieldonce[1] = true;
                                }
                                break;
                            case 2:
                                if(worldfieldonce[2]){
                                    worldfieldonce[2] = false;
                                }
                                else{
                                    DownDataWorldListInfo("worldfield","food");
                                    worldfieldonce[2] = true;
                                }
                                break;
                            case 3:
                                if(worldfieldonce[3]){
                                    worldfieldonce[3] = false;
                                }
                                else{
                                    DownDataWorldListInfo("worldfield","house");
                                    worldfieldonce[3] = true;
                                }
                                break;
                            case 4:
                                if(worldfieldonce[4]){
                                    worldfieldonce[4] = false;
                                }
                                else{
                                    DownDataWorldListInfo("worldfield","traffic");
                                    worldfieldonce[4] = true;
                                }
                                break;
                            case 5:
                                if(worldfieldonce[5]){
                                    worldfieldonce[5] = false;
                                }
                                else{
                                    DownDataWorldListInfo("worldfield","study");
                                    worldfieldonce[5] = true;
                                }
                                break;
                            case 6:
                                if(worldfieldonce[6]){
                                    worldfieldonce[6] = false;
                                }
                                else{
                                    DownDataWorldListInfo("worldfield","culture");
                                    worldfieldonce[6] = true;
                                }
                                break;
                            default:
                                break;
                        }
                        if(bindPageSlider != null){
                            bindPageSlider.setCurrentPage(tabList.getSelectedTabIndex(), true);
                        }
                        break;
                    case "fourthCenterTabList":
                        switch(tab.getPosition()){
                            case 0:
                                DataCenterControl.webView.load(DataCenterControl.messageNoticeUrlString);
                                break;
                            case 1:
                                if(messageonce[0]){
                                    messageonce[0] = false;
                                }
                                else{
                                    DownDataMessageListInfo("messageagree");
                                    messageonce[0] = true;
                                }
                                break;
                            case 2:
                                if(messageonce[1]){
                                    messageonce[1] = false;
                                }
                                else{
                                    DownDataMessageListInfo("messagediscuss");
                                    messageonce[1] = true;
                                }
                                break;
                            case 3:
                                if(messageonce[2]){
                                    messageonce[2] = false;
                                }
                                else{
                                    DownDataMessageListInfo("messagecollect");
                                    messageonce[2] = true;
                                }
                                break;
                            default:
                                break;
                        }
                        if(bindPageSlider != null){
                            bindPageSlider.setCurrentPage(tabList.getSelectedTabIndex(), true);
                        }
                        break;
                }
            }

            @Override
            public void onUnselected(TabList.Tab tab) {
                if(tabList.getName().equals("mainBottomTablist")) {
                    tab.setBackground(null);
                }
            }

            @Override
            public void onReselected(TabList.Tab tab) {
                if(tabList.getName().equals("fourthCenterTabList") && tab.getPosition() == 0) {
                    if(DataCenterControl.webView != null){
                        DataCenterControl.webView.load(DataCenterControl.messageNoticeUrlString);
                    }
                }
            }
        });

        if(tabListName.equals("mainBottomTablist")){
            TabList.Tab tab2 = deepdl_bottomdl_tablist.getTabAt(2);
            tab2.setClickedListener(new Component.ClickedListener() {
                @Override
                public void onClick(Component component) {
                    if(tab2.getText().equals(tabNames[2])){
                        if(DataCenterControl.webView != null){
                            DataCenterControl.webView.setVisibility(Component.INVISIBLE);
                        }
                        surfacedl.setVisibility(Component.VISIBLE);
                        tab2.setText("❌");
                    }
                }
            });
        }
        if(tabList.getTabCount() != 0 && !tabList.getName().equals("fourthCenterTabList")){
            tabList.selectTabAt(0);
        }
        else{
            tabList.selectTabAt(1);
        }
    }
    /*------------------------------------------初始化TabList区域---------------------------------->*/


    /*<----------------------------------------初始化ListContainer区域----------------------------------*/
    public static void initListContainer(ListContainer listContainer,String listContainerName,AbilitySlice slice,int typeN,int order){
        //oder:指明是那个Pa
        if(listContainer == null){
            return;
        }
        listContainer.setName(listContainerName);
        LCProviderForContent lcProviderForContent = null;
        LCProviderForNormal lcProviderForNormal = null;
        switch (typeN) {
            case 0:
                switch (order) {
                    case 0:
                        lcProviderForContent = new LCProviderForContent(DataCenterControl.worlddt_listcontainer_list,slice);
                        DataCenterControl.worldDtListContainerProvider = lcProviderForContent;
                        break;
                    case 1:
                        lcProviderForContent = new LCProviderForContent(DataCenterControl.worldxm_listcontainer_list,slice);
                        DataCenterControl.worldXmListContainerProvider = lcProviderForContent;
                        break;
                    case 2:
                        lcProviderForContent = new LCProviderForContent(DataCenterControl.worldwz_listcontainer_list,slice);
                        DataCenterControl.worldWzListContainerProvider = lcProviderForContent;
                        break;
                    default:
                        break;
                }
                break;
            case 1:
                switch (order) {
                    case 0:
                        lcProviderForContent = new LCProviderForContent(DataCenterControl.art_listcontainer_list,slice);
                        DataCenterControl.artListContainerProvider = lcProviderForContent;
                        break;
                    case 1:
                        lcProviderForContent = new LCProviderForContent(DataCenterControl.clothe_listcontainer_list,slice);
                        DataCenterControl.clotheListContainerProvider = lcProviderForContent;
                        break;
                    case 2:
                        lcProviderForContent = new LCProviderForContent(DataCenterControl.food_listcontainer_list,slice);
                        DataCenterControl.foodListContainerProvider = lcProviderForContent;
                        break;
                    case 3:
                        lcProviderForContent = new LCProviderForContent(DataCenterControl.house_listcontainer_list,slice);
                        DataCenterControl.houseListContainerProvider = lcProviderForContent;
                        break;
                    case 4:
                        lcProviderForContent = new LCProviderForContent(DataCenterControl.traffic_listcontainer_list,slice);
                        DataCenterControl.trafficListContainerProvider = lcProviderForContent;
                        break;
                    case 5:
                        lcProviderForContent = new LCProviderForContent(DataCenterControl.study_listcontainer_list,slice);
                        DataCenterControl.studyListContainerProvider = lcProviderForContent;
                        break;
                    case 6:
                        lcProviderForContent = new LCProviderForContent(DataCenterControl.culture_listcontainer_list,slice);
                        DataCenterControl.cultureListContainerProvider = lcProviderForContent;
                        break;
                    default:
                        break;
                }
                break;
            case 2:
                break;
            case 3:
                switch (order) {
                    case 0:
                        break;
                    case 1:
                        lcProviderForNormal = new LCProviderForNormal(DataCenterControl.messageagree_listcontainer_list,slice);
                        DataCenterControl.messageAgreeListContainerProvider = lcProviderForNormal;
                        break;
                    case 2:
                        lcProviderForNormal = new LCProviderForNormal(DataCenterControl.messagediscuss_listcontainer_list,slice);
                        DataCenterControl.messageDiscussListContainerProvider = lcProviderForNormal;
                        break;
                    case 3:
                        lcProviderForNormal = new LCProviderForNormal(DataCenterControl.messagecollect_listcontainer_list,slice);
                        DataCenterControl.messageCollectListContainerProvider = lcProviderForNormal;
                        break;
                    default:
                        break;
                }
                break;

            case 4:
                break;
            default:
                break;
        }

        if(lcProviderForContent != null){
            listContainer.setItemProvider(lcProviderForContent);
        }
        if(lcProviderForNormal != null){
            listContainer.setItemProvider(lcProviderForNormal);
        }

        listContainer.setItemClickedListener(new ListContainer.ItemClickedListener() {
            @Override
            public void onItemClicked(ListContainer listContainer, Component component, int i, long l) {
                Text typeText = (Text) ((DirectionalLayout)component).getComponentAt(0);
                switch(typeText.getText()){
                    case "项目":
                        slice.present(new XmDetails(),new Intent().setParam("listContainerName",listContainer.getName()).setParam("i", i));
                        break;
                    case "动态":
                    case "文章":
                        slice.present(new DtAndWzDetails(),new Intent().setParam("listContainerName",listContainer.getName()).setParam("i", i));
                        break;
                    default:
                        break;
                }
            }
        });
    }
    /*-----------------------------------------初始化ListContainer区域---------------------------------->*/



    /*<-----------------------------------------初始化MainAbilitySlice启动显示组件区域-----------------------------------*/
    private void initMASComponents(){
        //初始化启动页组件
        deepdl = (DirectionalLayout) findComponentById(ResourceTable.Id_deepdl);
        deepdl_topdl = (DirectionalLayout) findComponentById(ResourceTable.Id_deepdl_topdl);
        deepdl_centerdl = (DirectionalLayout) findComponentById(ResourceTable.Id_deepdl_centerdl);
        deepdl_bottomdl = (DirectionalLayout) findComponentById(ResourceTable.Id_deepdl_bottomdl);

        deepdl_bottomdl_tablist = (TabList) findComponentById(ResourceTable.Id_deepdl_bottomdl_tablist);

        surfacedl = (DirectionalLayout) findComponentById(ResourceTable.Id_surfacedl);
        surfacedl_writeselect = (DirectionalLayout) findComponentById(ResourceTable.Id_surfacedl_writeselect);

        dt_but = (Button) findComponentById(ResourceTable.Id_dt_but);
        xm_but = (Button) findComponentById(ResourceTable.Id_xm_but);
        wz_but = (Button) findComponentById(ResourceTable.Id_wz_but);


        surfacedl.setClickedListener(new Component.ClickedListener() {
            @Override
            public void onClick(Component component) {
                surfacedl.setVisibility(Component.HIDE);
                if(DataCenterControl.webView != null){
                    DataCenterControl.webView.setVisibility(Component.VISIBLE);
                }
                TabList.Tab tab2 = deepdl_bottomdl_tablist.getTabAt(2);
                tab2.setText(bottomTabNames[2]);
            }
        });
        dt_but.setClickedListener(new Component.ClickedListener() {
            @Override
            public void onClick(Component component) {
                surfacedl.getClickedListener().onClick(surfacedl);
                present(new EditDtDetailSlice(),new Intent());
            }
        });
        xm_but.setClickedListener(new Component.ClickedListener() {
            @Override
            public void onClick(Component component) {
                surfacedl.getClickedListener().onClick(surfacedl);
                present(new EditXmDetailSlice(),new Intent());
            }
        });
        wz_but.setClickedListener(new Component.ClickedListener() {
            @Override
            public void onClick(Component component) {
                surfacedl.getClickedListener().onClick(surfacedl);
                present(new EditWzDetailSlice(),new Intent());
            }
        });
    }
    /*------------------------------------------初始化MainAbilitySlice启动显示组件区域---------------------------------->*/

    /*<-----------------------------------------生命周期函数区域-----------------------------------*/
    @Override
    public void onStart(Intent intent) {
        super.onStart(intent);
        super.setUIContent(ResourceTable.Layout_ability_main);

        initMASComponents();
        initTabList(deepdl_bottomdl_tablist,bottomTabNames,"mainBottomTablist",null);
    }

    @Override
    protected void onActive() {
        super.onActive();
    }

    @Override
    protected void onInactive() {
        super.onInactive();
        if(toanotherslice){
            terminate();
        }
    }

    @Override
    protected void onForeground(Intent intent) {
        super.onForeground(intent);
    }

    @Override
    protected void onBackground() {
        super.onBackground();
    }

    @Override
    protected void onStop() {
        super.onStop();
    }
    /*------------------------------------------生命周期函数区域---------------------------------->*/
}
